package com.cloud.spring.demo.controller;

import com.cloud.spring.demo.entity.User;
import com.cloud.spring.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("test")
public class TestController {
    @Autowired
    UserService userService;

    @GetMapping("insert")
    public User insert(User user) {
        return userService.insert(user);
    }

    @GetMapping("delete")
    public User delete(User user) {
        return userService.delete(user);
    }

    @GetMapping("clearUserAll")
    public void clearUserAll() {
        userService.clearUser1All();
    }

    @GetMapping("update")
    public User update(User user) {
        return userService.update(user);
    }

    @GetMapping("findUser")
    public User findUser(int id) {
        return userService.findUser(id);
    }

    @GetMapping("findUserList")
    public List<User> findUserList() {
        return userService.findUserList();
    }

}
